package com.wy17113.model.service.impl;

import java.sql.SQLException;
import java.util.List;

import com.wy17113.model.dao.ILifeInfoDao;
import com.wy17113.model.entity.Common;
import com.wy17113.model.entity.LifeInfo;
import com.wy17113.model.service.ILifeInfoService;

public class LifeInfoServiceImpl implements ILifeInfoService {
	private ILifeInfoDao lifeInfoDao;
		
	public ILifeInfoDao getLifeInfoDao() {
		return lifeInfoDao;
	}

	public void setLifeInfoDao(ILifeInfoDao lifeInfoDao) {
		this.lifeInfoDao = lifeInfoDao;
	}

	////////////////////////////////////////////////////////////////////////
	
	public int getLifeInfoListCounts(int typeId,String userId,String flag) {		
		return lifeInfoDao.getLifeInfoListCounts(typeId,userId,flag);
	}

	public List<LifeInfo> getLifeInfoList(int typeId,String userId, int startIndex,
			int pageRowCount,String flag) {
		List<LifeInfo> lifeInfoList = lifeInfoDao.getLifeInfoList(typeId,userId,startIndex,pageRowCount,flag);
		for(LifeInfo li : lifeInfoList){
			li.setSubDate(li.getSubDate().substring(5,10));
		}
		return lifeInfoList;
	}

	public void saveLifeInfo(LifeInfo li) throws SQLException {
		lifeInfoDao.saveLifeInfo(li);
	}

	public LifeInfo getLifeInfoById(String id) throws SQLException {		
		return lifeInfoDao.getLifeInfoById(id);
	}

	public void deleteLifeInfos(String[] allId) {
		lifeInfoDao.deleteLifeInfos(allId);
	}

	public void shenHeLifeInfos(String[] ids) throws Exception {
		lifeInfoDao.shenHeLifeInfos(ids);
	}

	public void zhiDingLifeInfo(String id) {
		lifeInfoDao.zhiDingLifeInfo(id);
	}

	public int getMaxSort() {
		return lifeInfoDao.getMaxSort();
	}

	public List<Common> getCommonListByInfoId(String infoId, int startIndex,
			int pageRowCount) throws Exception {
		List<Common> commonList = lifeInfoDao.getCommonListByInfoId(infoId, startIndex, pageRowCount);
		for(Common com : commonList){
			com.setSubDate(com.getSubDate().substring(0,10));
		}
		return commonList;
	}

	public int getCommonCountByInfoId(String infoId) throws Exception {
		return lifeInfoDao.getCommonCountByInfoId(infoId);
	}

	public int getMaxCommonSort(String infoId) {
		return lifeInfoDao.getMaxCommonSort(infoId);
	}

	public void saveCommon(Common com) throws SQLException {
		lifeInfoDao.saveCommon(com);
	}

	public void deleteCommons(String[] ids) {
		lifeInfoDao.deleteCommons(ids);
	}

	public void updateClicksById(String infoId) {
		lifeInfoDao.updateClicksById(infoId);
	}

	public void updateLifeInfoUpdateDate(String infoId,String updateDate) {
		lifeInfoDao.updateLifeInfoUpdateDate(infoId,updateDate);
	}
}
